home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Presentations
/
Presentations ’88
/
Fritz Proceedings stuff
/
PatchLMgr.c
< prev
next >
Wrap
Text File
|
1988-06-14
|
3KB
|
118 lines
/*
* PatchLMgr.c
*
* Created Thursday, March 31, 1988 5:10:17 PM
*/
#include <QuickDraw.h>
#include "SetEditor.h"
typedef struct {
short baseLine;
RgnHandle cellRgn;
} LRefCon, *LRCPtr, **LRCHandle;
#define LBaseLine(list) ((*(LRCHandle)(*list)->refCon)->baseLine)
#define LCellRgn(list) ((*(LRCHandle)(*list)->refCon)->cellRgn)
/*
* Our story so far:
*
* When a list is scrolled, the List Manager calls LUpdate internally,
* drawing all the cells that are exposed; it then disposes of ScrollRect's
* invalidation region. All very well, but the List Manager no longer
* knows all there is to know about the state of a set editor list:
* The UI application itself handles highlighting of units larger than
* single cells. The result is that when cells in a highlighted row or
* column are drawn unhighlighted when they are exposed, and the UI is
* never notified of an update.
*
* The solution is to patch _Pack0 (the List Manager dispatcher) at LUpdate;
* At that point, we can take note of the invalid region, clip to it, and
* highlight.
*
* We can also take this opportunity to install the long-awaited patch
* that will allow the labels to be drawn in synch with a scrolling array.
* The List Manager never calls its mouseDown hook when a list's scroll bars
* are hit, and so this is the best available hook.
*
* The actual patch should be in assembly language, which will save us
* the trouble of always doing the right thing by _Pack0's variable-length
* argument list. This file contains only the high-level parts of the patch;
* the glue is in PatchLMgr.a.
*/
#define __SEG__ Init
InstallPatch()
{
LUPatIn();
}
#define __SEG__ Main
LUpdatePatch(lHandle, theRgn)
ListHandle lHandle;
RgnHandle theRgn;
{
RgnHandle tempRgn,
freshRgn;
SetEdPtr theWindow;
GrafPtr oldPort;
theWindow = (*lHandle)->port;
if (Peek(theWindow)->windowKind != setEditor)
return;
GetPort(&oldPort);
SetPort(theWindow);
tempRgn = NewRgn();
GetClip(tempRgn);
UnionRgn(LCellRgn(lHandle), theRgn, freshRgn = NewRgn());
SetClip(freshRgn);
DisposeRgn(freshRgn);
AdjustLabels(theWindow);
InvertSel(theWindow);
SetClip(tempRgn);
DisposeRgn(tempRgn);
SetPort(oldPort);
}
/* The following patch, believe it or not, does _not_
* re-enter. The actual patch code directs all calls
* to ScrollRect(), other than from the List Manager,
* to the trap itself.
*/
pascal void MyScrRect(r, dh, dv, updateRgn)
Rect *r;
short dh,
dv;
RgnHandle updateRgn;
{
SetEdPtr theWindow;
Rect myRect;
ListHandle SEList();
GetPort(&theWindow);
if (Peek(theWindow)->windowKind == setEditor) {
/* First, expand the scrolling Rect to include the labels: */
myRect = *r;
if (dh) {
myRect.top -= TITLE_HEIGHT;
}
else if (dv) {
myRect.left -= LABEL_WIDTH;
}
ScrollRect(&myRect, dh, dv, updateRgn);
SetEmptyRgn(LCellRgn(SEList(theWindow)));
}
else
ScrollRect(r, dh, dv, updateRgn);
}